home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wpopup.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  91 lines

  1. ; $Id: wpopup.pro,v 1.3 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple "pop-up" widget.
  7. ; In this example, a new base with a button in it appears
  8. ; when a button in the original base, labeled "Create Popup",
  9. ; is pressed.
  10.  
  11.  
  12.  
  13. PRO wpopup_event, event
  14. ; This is the event handler for a "pop-up" widget.
  15.  
  16. ; The COMMON block is used because both wpopup and wpopup_event must
  17. ; know about the group leader.
  18. COMMON groupleader, base
  19.  
  20. ; Use WIDGET_CONTROL to get the user value of any widget touched and put
  21. ; that value into 'eventval':
  22.  
  23. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  24.  
  25. ; Perform actions based on the user value of the button which was pressed.
  26.  
  27. CASE eventval OF
  28.     'POPUP':     BEGIN
  29.             popupbase = WIDGET_BASE()
  30.  
  31.             popupbutton = WIDGET_BUTTON(popupbase, $
  32.                         UVALUE = 'GOBACK', $
  33.                 VALUE = 'Go Back', $
  34.                 XSIZE=200, YSIZE=60)
  35.  
  36.             ; Desensitize the parent of popup
  37.             WIDGET_CONTROL, base, SENSITIVE=0
  38.  
  39.             ; Realize the popup:
  40.             WIDGET_CONTROL, popupbase, /REALIZE
  41.  
  42.             ; Hand off control of the widget to the XMANAGER:
  43.             XMANAGER, "wpopup", popupbase, GROUP_LEADER=base, $
  44.                       /NO_BLOCK
  45.               END
  46.  
  47.    'DONE': WIDGET_CONTROL, event.top, /DESTROY
  48.  
  49.    'GOBACK': BEGIN
  50.                 WIDGET_CONTROL, event.top, /DESTROY
  51.  
  52.                 ; Re-sensitize the main base
  53.                 WIDGET_CONTROL, base, SENSITIVE=1
  54.            END
  55.  
  56. ENDCASE
  57. END
  58.  
  59.  
  60.  
  61. PRO wpopup, GROUP=GROUP
  62. ; This is the procedure that creates a widget application
  63.  
  64. ; The COMMON block is used because both wpopup and wpopup_event must
  65. ; know the group leader.
  66. COMMON groupleader, base
  67.  
  68. ; A top-level base widget with the title "Pop-Up Widget Example" will
  69. ; hold the exclusive buttons:
  70. base = WIDGET_BASE(TITLE = 'Pop-Up Widget Example', $
  71.     /COLUMN, $
  72.     XSIZE=200)
  73.  
  74. button1 = WIDGET_BUTTON(base, $
  75.                 UVALUE = 'DONE', $
  76.                 VALUE = 'DONE')
  77.  
  78. button2 = WIDGET_BUTTON(base, $
  79.                 UVALUE = 'POPUP', $
  80.                 VALUE = 'Create Popup')
  81.  
  82. ; Realize the widgets:
  83. WIDGET_CONTROL, base, /REALIZE
  84.  
  85. ; Hand off control of the widget to the XMANAGER:
  86. XMANAGER, "wpopup", base, GROUP_LEADER=GROUP, /NO_BLOCK
  87.  
  88. END
  89.  
  90.  
  91.